package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.SuggestDao;
import com.itheima.entity.PageResult;
import com.itheima.pojo.Suggest;
import com.itheima.service.SuggestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = SuggestService.class)
@Transactional
public class SuggestServiceImpl implements SuggestService {
    @Autowired
    private SuggestDao suggestDao;

    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage, pageSize);
        Page<PageResult> page = suggestDao.findPage(queryString);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public void add(Suggest suggest) {
        suggestDao.add(suggest);
    }

    @Override
    public Suggest findById(Integer id) {
        Suggest byId = suggestDao.findById(id);
        return byId;
    }

    @Override
    public void edit(Suggest suggest) {
      suggestDao.edit(suggest);
    }

    @Override
    public void delete(Integer id) {
       suggestDao.delete(id);
    }


}
